package com.csoa.community.db;

import java.util.ArrayList;
import java.util.List;

import android.database.Cursor;

import com.csoa.community.bean.DataStatisticsBean;
import com.csoa.community.bean.WZMLInfoBean;
import com.csoa.community.singletons.GlobalVars;

public class WZMLInfoDB extends DataBaseDB {

	/**
	 * 样方信息插入操作
	 * @param lm
	 */
	//总共33项
	public static void insert(WZMLInfoBean wzmlInfo) {
		DataBaseDB.getInst().getDB();
		String sql = "insert into WZMLInfoTable(" +
				"grounpId ," + // 课题组id
				"surveyMethod  ," + // 所属调查方法
				"surveyArea  ," + // 调查区域
				"surveyAreaPosition  ," + // 调查区域
				"chineseName  ," + // 中文名
				"latinName  ," + // 拉丁名称
				"commonName  ," + // 俗名
				"characters  ," + // 习性
				"distributionTypePosition  ," + // 习性
				"distributionArea  ," + // 分布区域
				"environmentFeature  ," + // 生活环境
				"elevationBegin  ," + // 海拔
				"elevationEnd  ," + // 海拔
				"level  ," + // 习性
				"niche  ," + // 习性
				"isOrigin  ," + // 是否原产
				"endemism  ," + // 特有性
				"degrees  ," + // 多度
				"use  ," + // 用途
				"nationalUse  ," + // 民族用途
				"threatStates  ," + // 受威胁现状
				"threatFactors  ," + // 受威胁因素
				"saveGradeInCountry  ," + // 保护等级
				"saveGradeInPrivince  ," + // 保护等级
				"saveGradeInCITES  ," + // 保护等级
				"saveGradeInRed  ," + // 保护等级
				"imgPath," +
				"imgTitle,"+ 
				"imgAuthor,"+ 
				"videoPath," +
				"videoTitle," + // luxiang
				"videoAuthor," + // zhaopian
				"saveStates " + // 保护状态
				") values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
		db.beginTransaction();
		try {
			db.execSQL(sql, new String[] { 
					wzmlInfo.groupId, 
					wzmlInfo.surveyMethod,
					wzmlInfo.surveyArea,
					String.valueOf(wzmlInfo.surveyAreaPosition),
					wzmlInfo.chineseName, 
					wzmlInfo.latinName, 
					wzmlInfo.commonName,
					String.valueOf(wzmlInfo.characters),
					String.valueOf(wzmlInfo.distributionTypePosition),
					wzmlInfo.distributionArea,
					wzmlInfo.environmentFeature,
					wzmlInfo.elevationBegin,
					wzmlInfo.elevationEnd,
					String.valueOf(wzmlInfo.level),
					String.valueOf(wzmlInfo.niche),
					String.valueOf(wzmlInfo.isOrigin),
					String.valueOf(wzmlInfo.endemism),
					String.valueOf(wzmlInfo.degrees),
					wzmlInfo.use,
					wzmlInfo.nationalUse,
					String.valueOf(wzmlInfo.threatStates),
					wzmlInfo.threatFactors, 
					String.valueOf(wzmlInfo.saveGradeInCountry),
					String.valueOf(wzmlInfo.saveGradeInPrivince),
					String.valueOf(wzmlInfo.saveGradeInCITES),
					String.valueOf(wzmlInfo.saveGradeInRed),
					wzmlInfo.imgPath,
					wzmlInfo.imgTitle,
					wzmlInfo.imgAuthor,
					wzmlInfo.videoPath,
					wzmlInfo.videoTitle,
					wzmlInfo.videoAuthor,
					String.valueOf(wzmlInfo.saveStates),
					});
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			if (db.isOpen()) {
				db.setTransactionSuccessful();
				db.endTransaction();
				db.close();
			}
		}
	}
	
	
	
	/**
	 * 解析物种对象
	 * @param wzInfo
	 * @param cursor 
	 */
	private static DataStatisticsBean parseDataStatistic(Cursor cursor) {
		DataStatisticsBean data = new DataStatisticsBean();
		data.id = cursor.getInt(cursor
				.getColumnIndex("id"));
		data.groupId = cursor.getString(cursor
				.getColumnIndex("grounpId"));
		data.surveyMethod = cursor.getString(cursor
				.getColumnIndex("surveyMethod"));
		
		data.surveyArea = cursor.getString(cursor
				.getColumnIndex("surveyArea"));
		data.chineseName = cursor.getString(cursor
				.getColumnIndex("chineseName"));
		data.latinName = cursor.getString(cursor
				.getColumnIndex("latinName"));
		data.type = "植物";
		return data;
	}
	/**
	 * 解析物种对象
	 * @param wzInfo
	 * @param cursor 
	 */
	private static WZMLInfoBean parseWZMLInfo(Cursor cursor) {
		WZMLInfoBean wzmlInfo = new WZMLInfoBean();
		wzmlInfo.id = cursor.getInt(cursor
				.getColumnIndex("id"));
		wzmlInfo.groupId = cursor.getString(cursor
				.getColumnIndex("grounpId"));
		wzmlInfo.surveyMethod = cursor.getString(cursor
				.getColumnIndex("surveyMethod"));
		
		wzmlInfo.surveyArea = cursor.getString(cursor
				.getColumnIndex("surveyArea"));
		wzmlInfo.surveyAreaPosition = cursor.getInt(cursor
				.getColumnIndex("surveyAreaPosition"));
		wzmlInfo.chineseName = cursor.getString(cursor
				.getColumnIndex("chineseName"));
		wzmlInfo.latinName = cursor.getString(cursor
				.getColumnIndex("latinName"));
		wzmlInfo.commonName = cursor.getString(cursor
				.getColumnIndex("commonName"));
		
		
		wzmlInfo.characters = cursor.getInt(cursor
				.getColumnIndex("characters"));
		wzmlInfo.distributionTypePosition = cursor.getInt(cursor
				.getColumnIndex("distributionTypePosition"));
		wzmlInfo.distributionArea = cursor.getString(cursor
				.getColumnIndex("distributionArea"));
		wzmlInfo.environmentFeature = cursor.getString(cursor
				.getColumnIndex("environmentFeature"));
		wzmlInfo.elevationBegin = cursor.getString(cursor
				.getColumnIndex("elevationBegin"));
		wzmlInfo.elevationEnd = cursor.getString(cursor
				.getColumnIndex("elevationEnd"));
		wzmlInfo.level = cursor.getInt(cursor
				.getColumnIndex("level"));
		wzmlInfo.niche = cursor.getInt(cursor
				.getColumnIndex("niche"));
		wzmlInfo.isOrigin = cursor.getInt(cursor
				.getColumnIndex("isOrigin"));
		wzmlInfo.endemism = cursor.getInt(cursor
				.getColumnIndex("endemism"));
		wzmlInfo.niche = cursor.getInt(cursor
				.getColumnIndex("niche"));
		wzmlInfo.degrees = cursor.getInt(cursor
				.getColumnIndex("degrees"));
		wzmlInfo.use = cursor.getString(cursor
				.getColumnIndex("use"));
		wzmlInfo.nationalUse = cursor.getString(cursor
				.getColumnIndex("nationalUse"));
		wzmlInfo.threatStates = cursor.getInt(cursor
				.getColumnIndex("threatStates"));
		wzmlInfo.threatFactors = cursor.getString(cursor
				.getColumnIndex("threatFactors"));
		wzmlInfo.saveGradeInCountry = cursor.getInt(cursor
				.getColumnIndex("saveGradeInCountry"));
		wzmlInfo.saveGradeInPrivince = cursor.getInt(cursor
				.getColumnIndex("saveGradeInPrivince"));
		wzmlInfo.saveGradeInCITES = cursor.getInt(cursor
				.getColumnIndex("saveGradeInCITES"));
		wzmlInfo.saveGradeInRed = cursor.getInt(cursor
				.getColumnIndex("saveGradeInRed"));
		
		wzmlInfo.imgPath = cursor.getString(cursor
				.getColumnIndex("imgPath"));
		wzmlInfo.imgTitle = cursor.getString(cursor
				.getColumnIndex("imgTitle"));
		wzmlInfo.imgAuthor = cursor.getString(cursor
				.getColumnIndex("imgAuthor"));
		wzmlInfo.videoPath = cursor.getString(cursor
				.getColumnIndex("videoPath"));
		wzmlInfo.videoTitle = cursor.getString(cursor
				.getColumnIndex("videoTitle"));
		wzmlInfo.videoAuthor = cursor.getString(cursor
				.getColumnIndex("videoAuthor"));
		
		wzmlInfo.saveStates = cursor.getInt(cursor
				.getColumnIndex("saveStates"));
		return wzmlInfo;
	}
//
	/**
	 * 查询所有样方信息
	 * 
	 * @param lm
	 */
	public static List<WZMLInfoBean> query(int page) {
		if(page <= 0) {
			page = 1;
		}
		DataBaseDB.getInst().getDB();
		String sql = "select " +
				"id," +
				"grounpId ," + // 课题组id
				"surveyMethod  ," + // 所属调查方法
				"surveyArea  ," + // 调查区域
				"surveyAreaPosition  ," + // 调查区域
				"chineseName  ," + // 中文名
				"latinName  ," + // 拉丁名称
				"commonName  ," + // 俗名
				"characters  ," + // 习性
				"distributionTypePosition  ," + // 习性
				"distributionArea  ," + // 分布区域
				"environmentFeature  ," + // 生活环境
				"elevationBegin  ," + // 海拔
				"elevationEnd  ," + // 海拔
				"level  ," + // 习性
				"niche  ," + // 习性
				"isOrigin  ," + // 是否原产
				"endemism  ," + // 特有性
				"degrees  ," + // 多度
				"use  ," + // 用途
				"nationalUse  ," + // 民族用途
				"threatStates  ," + // 受威胁现状
				"threatFactors  ," + // 受威胁因素
				"saveGradeInCountry  ," + // 保护等级
				"saveGradeInPrivince  ," + // 保护等级
				"saveGradeInCITES  ," + // 保护等级
				"saveGradeInRed  ," + // 保护等级
				"imgPath," +
				"imgTitle,"+ 
				"imgAuthor,"+ 
				"videoPath," +
				"videoTitle," + // luxiang
				"videoAuthor," + // zhaopian
				"saveStates " + // 保护状态
				" from WZMLInfoTable order by id desc limit ?, ?";
		db.beginTransaction();
		Cursor cursor = null;
		List<WZMLInfoBean> wzmlInfos = null;
		try {
			cursor = db.rawQuery(sql, new String[]{String.valueOf(GlobalVars.PAGE_COUNT*(page-1)),String.valueOf(GlobalVars.PAGE_COUNT*page)});
			if (cursor.getCount() > 0) {
				wzmlInfos = new ArrayList<WZMLInfoBean>();
				while (cursor.moveToNext()) {
					WZMLInfoBean wzmlInfo = parseWZMLInfo(cursor);
					wzmlInfos.add(wzmlInfo);
				}

			}

		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			if (cursor != null) {
				cursor.close();
				cursor = null;

			}
			if (db.isOpen()) {
				db.setTransactionSuccessful();
				db.endTransaction();
				db.close();
			}
		}
		return wzmlInfos;
	}
	
	
	/**
	 * 查询所有样方信息
	 * 
	 * @param lm
	 */
	public static List<DataStatisticsBean> queryStatistic() {
		DataBaseDB.getInst().getDB();
		String sql = "select " +
				"id," +
				"grounpId ," + // 课题组id
				"surveyMethod  ," + // 所属调查方法
				"surveyArea  ," + // 调查区域
				"surveyAreaPosition  ," + // 调查区域
				"chineseName  ," + // 中文名
				"latinName  ," + // 拉丁名称
				"commonName  ," + // 俗名
				"characters  ," + // 习性
				"distributionTypePosition  ," + // 习性
				"distributionArea  ," + // 分布区域
				"environmentFeature  ," + // 生活环境
				"elevationBegin  ," + // 海拔
				"elevationEnd  ," + // 海拔
				"level  ," + // 习性
				"niche  ," + // 习性
				"isOrigin  ," + // 是否原产
				"endemism  ," + // 特有性
				"degrees  ," + // 多度
				"use  ," + // 用途
				"nationalUse  ," + // 民族用途
				"threatStates  ," + // 受威胁现状
				"threatFactors  ," + // 受威胁因素
				"saveGradeInCountry  ," + // 保护等级
				"saveGradeInPrivince  ," + // 保护等级
				"saveGradeInCITES  ," + // 保护等级
				"saveGradeInRed  ," + // 保护等级
				"imgPath," +
				"imgTitle,"+ 
				"imgAuthor,"+ 
				"videoPath," +
				"videoTitle," + // luxiang
				"videoAuthor," + // zhaopian
				"saveStates " + // 保护状态
				" from WZMLInfoTable order by id desc";
		db.beginTransaction();
		Cursor cursor = null;
		List<DataStatisticsBean> datas = null;
		try {
			cursor = db.rawQuery(sql, null);
			if (cursor.getCount() > 0) {
				datas = new ArrayList<DataStatisticsBean>();
				while (cursor.moveToNext()) {
					DataStatisticsBean data = parseDataStatistic(cursor);
					datas.add(data);
				}

			}

		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			if (cursor != null) {
				cursor.close();
				cursor = null;

			}
			if (db.isOpen()) {
				db.setTransactionSuccessful();
				db.endTransaction();
				db.close();
			}
		}
		return datas;
	}
	
	
	public static List<DataStatisticsBean> queryStatistic(String type,String surveyMethod, String surveyArea,String chineseName) {
		DataBaseDB.getInst().getDB();
		String sql = "select " +
				"id," +
				"grounpId ," + // 课题组id
				"surveyMethod  ," + // 所属调查方法
				"surveyArea  ," + // 调查区域
				"surveyAreaPosition  ," + // 调查区域
				"chineseName  ," + // 中文名
				"latinName  ," + // 拉丁名称
				"commonName  ," + // 俗名
				"characters  ," + // 习性
				"distributionTypePosition  ," + // 习性
				"distributionArea  ," + // 分布区域
				"environmentFeature  ," + // 生活环境
				"elevationBegin  ," + // 海拔
				"elevationEnd  ," + // 海拔
				"level  ," + // 习性
				"niche  ," + // 习性
				"isOrigin  ," + // 是否原产
				"endemism  ," + // 特有性
				"degrees  ," + // 多度
				"use  ," + // 用途
				"nationalUse  ," + // 民族用途
				"threatStates  ," + // 受威胁现状
				"threatFactors  ," + // 受威胁因素
				"saveGradeInCountry  ," + // 保护等级
				"saveGradeInPrivince  ," + // 保护等级
				"saveGradeInCITES  ," + // 保护等级
				"saveGradeInRed  ," + // 保护等级
				"imgPath," +
				"imgTitle,"+ 
				"imgAuthor,"+ 
				"videoPath," +
				"videoTitle," + // luxiang
				"videoAuthor," + // zhaopian
				"saveStates " + // 保护状态
				" from WZMLInfoTable where " +
				"surveyMethod like ? and " +
				"chineseName like ? and " +
				"surveyArea like ?  " +
				"order by id desc";
		db.beginTransaction();
		Cursor cursor = null;
		List<DataStatisticsBean> datas = null;
		try {
			cursor = db.rawQuery(sql, new String [] {"%" + surveyMethod + "%","%" + chineseName + "%","%" + surveyArea + "%"});
			if (cursor.getCount() > 0) {
				datas = new ArrayList<DataStatisticsBean>();
				while (cursor.moveToNext()) {
					DataStatisticsBean data = parseDataStatistic(cursor);
					datas.add(data);
				}

			}

		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			if (cursor != null) {
				cursor.close();
				cursor = null;

			}
			if (db.isOpen()) {
				db.setTransactionSuccessful();
				db.endTransaction();
				db.close();
			}
		}
		return datas;
	}
//	
//	
//	/**
//	 * 查询所有样方信息
//	 * 
//	 * @param lm
//	 */
//	public static List<WZMLInfoBean> query(int yfid) {
//		DataBaseDB.getInst().getDB();
//		String sql = "select " +
//				"id," +
//				"yfId," +
//				"grounpId ," + // 课题组id
//				"surveyMethod  ," + // 所属调查方法
//				"chineseName  ," + // 中文名
//				"latinName  ," + // 拉丁名称
//				"commonName  ," + // 俗名
//				"characters  ," + // 性状
//				"quantity  ," + // 数量
//				"coverage  ," + // 盖度
//				"height  ," + // 高度
//				"frequentness  ," + // 高度
//				"DBH  ," + // 胸径
//				"phenology  ," + // 物候
//				"phenologyPosition  ," + // 物候
//				"viability  ," + // 生活力
//				"viabilityPosition  ," + // 生活力
//				"niche  ," + // 生态位
//				"nichePosition  ," + // 生态位
//				"threatFactors  ," + // 受威胁因素
//				"specimenNumber  ," + // 标本号
//				"photoNumber ," + // 照片号
//				"smallQuadratNumber ," + // 小样方号
//				"importantLevel ," + // 重要级别
//				"level ," + // 层次
//				"levelPosition ," + // 层次
//				"formations ," + // 群系
//				"distributionType ," + // 分布类型
//				"distributionTypePosition ," + // 分布类型
//				"distributionArea " + // 分布区域
//				" from WZMLInfoTable where yfId=? order by id desc";
//		db.beginTransaction();
//		Cursor cursor = null;
//		List<WZMLInfoBean> wzInfos = null;
//		try {
//			cursor = db.rawQuery(sql, new String[]{String.valueOf(yfid)});
//			if (cursor.getCount() > 0) {
//				wzInfos = new ArrayList<WZMLInfoBean>();
//				while (cursor.moveToNext()) {
//					WZMLInfoBean wzInfo = parseWZInfo(cursor);
//					wzInfos.add(wzInfo);
//				}
//
//			}
//
//		} catch (Exception e) {
//			e.printStackTrace();
//		} finally {
//			if (cursor != null) {
//				cursor.close();
//				cursor = null;
//
//			}
//			if (db.isOpen()) {
//				db.setTransactionSuccessful();
//				db.endTransaction();
//				db.close();
//			}
//		}
//		return wzInfos;
//	}
//	
//	
//	/**
//	 * 
//	 * @param yfId
//	 * @return
//	 */
//	public static int getWZCount(int yfId) {
//		DataBaseDB.getInst().getDB();
//		String sql = "select count(*) from WZMLInfoTable where yfId=" + yfId;
//		db.beginTransaction();
//		Cursor cursor = null;
//		int count = 0;
//		try {
//			cursor = db.rawQuery(sql, null);
//			if (cursor.getCount() > 0) {
//				cursor.moveToNext();
//				count = cursor.getInt(0);
//			}
//
//		} catch (Exception e) {
//			e.printStackTrace();
//		} finally {
//			if (cursor != null) {
//				cursor.close();
//				cursor = null;
//
//			}
//			if (db.isOpen()) {
//				db.setTransactionSuccessful();
//				db.endTransaction();
//				db.close();
//			}
//		}
//		return count;
//	}
//	
//	
	/**
	 * 查询所有样方信息
	 * 
	 * @param lm
	 */
	public static List<WZMLInfoBean> query(String latinName,String chineseName,String area) {
		DataBaseDB.getInst().getDB();
		String sql = "select " +
				"id," +
				"grounpId ," + // 课题组id
				"surveyMethod  ," + // 所属调查方法
				"surveyArea  ," + // 调查区域
				"surveyAreaPosition  ," + // 调查区域
				"chineseName  ," + // 中文名
				"latinName  ," + // 拉丁名称
				"commonName  ," + // 俗名
				"characters  ," + // 习性
				"distributionTypePosition  ," + // 习性
				"distributionArea  ," + // 分布区域
				"environmentFeature  ," + // 生活环境
				"elevationBegin  ," + // 海拔
				"elevationEnd  ," + // 海拔
				"level  ," + // 习性
				"niche  ," + // 习性
				"isOrigin  ," + // 是否原产
				"endemism  ," + // 特有性
				"degrees  ," + // 多度
				"use  ," + // 用途
				"nationalUse  ," + // 民族用途
				"threatStates  ," + // 受威胁现状
				"threatFactors  ," + // 受威胁因素
				"saveGradeInCountry  ," + // 保护等级
				"saveGradeInPrivince  ," + // 保护等级
				"saveGradeInCITES  ," + // 保护等级
				"saveGradeInRed  ," + // 保护等级
				"imgPath," +
				"imgTitle,"+ 
				"imgAuthor,"+ 
				"videoPath," +
				"videoTitle," + // luxiang
				"videoAuthor," + // zhaopian
				"saveStates " + // 保护状态
				" from WZMLInfoTable where " +
				"latinName like ? and " +
				"chineseName like ? and " +
				"surveyArea like ?  " +
				"order by id desc";
		db.beginTransaction();
		Cursor cursor = null;
		List<WZMLInfoBean> wzmlInfos = null;
		try {
			cursor = db.rawQuery(sql, new String[]{"%" + latinName + "%","%" + chineseName + "%","%" + area + "%"});
			if (cursor.getCount() > 0) {
				wzmlInfos = new ArrayList<WZMLInfoBean>();
				while (cursor.moveToNext()) {
					WZMLInfoBean wzmlInfo = parseWZMLInfo(cursor);
					wzmlInfos.add(wzmlInfo);
				}

			}

		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			if (cursor != null) {
				cursor.close();
				cursor = null;

			}
			if (db.isOpen()) {
				db.setTransactionSuccessful();
				db.endTransaction();
				db.close();
			}
		}
		return wzmlInfos;
	}
//	
//	
//
	/**
	 * 删除某一个用户的登录信息
	 * 
	 * @param LoginBean
	 */
	public static void delete(WZMLInfoBean wzmlInfo) {
		DataBaseDB.getInst().getDB();
		String del = "delete from WZMLInfoTable where id=?";
		db.beginTransaction();
		try {
			db.execSQL(del,
					new String[] { String.valueOf(wzmlInfo.id) });
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			if (db.isOpen()) {
				db.setTransactionSuccessful();
				db.endTransaction();
				db.close();
			}
		}

	}
//	
//	public static void delete() {
//		DataBaseDB.getInst().getDB();
//		String del = "delete from WZMLInfoTable ";
//		db.beginTransaction();
//		try {
//			db.execSQL(del,
//					null);
//		} catch (Exception e) {
//			e.printStackTrace();
//		} finally {
//			if (db.isOpen()) {
//				db.setTransactionSuccessful();
//				db.endTransaction();
//				db.close();
//			}
//		}
//
//	}
//
	/**
	 * 更新物种信息
	 * 
	 * @param lm
	 */
	public static boolean updateById(WZMLInfoBean wzmlInfo,int id) {
		DataBaseDB.getInst().getDB();
		String sql = "update WZMLInfoTable set " +
				"surveyArea=?  ," + // 调查区域
				"surveyAreaPosition=?  ," + // 调查区域
				"chineseName=?  ," + // 中文名
				"latinName=?  ," + // 拉丁名称
				"commonName=?  ," + // 俗名
				"characters=?  ," + // 习性
				"distributionTypePosition=?  ," + // 习性
				"distributionArea=?  ," + // 分布区域
				"environmentFeature=?  ," + // 生活环境
				"elevationBegin=?  ," + // 海拔
				"elevationEnd=?  ," + // 海拔
				"level=?  ," + // 习性
				"niche=?  ," + // 习性
				"isOrigin=?  ," + // 是否原产
				"endemism=?  ," + // 特有性
				"degrees=?  ," + // 多度
				"use=?  ," + // 用途
				"nationalUse=?  ," + // 民族用途
				"threatStates=?  ," + // 受威胁现状
				"threatFactors=?  ," + // 受威胁因素
				"saveGradeInCountry=?  ," + // 保护等级
				"saveGradeInPrivince=?  ," + // 保护等级
				"saveGradeInCITES=?  ," + // 保护等级
				"saveGradeInRed=?  ," + // 保护等级
				"imgPath=?," +
				"imgTitle=?,"+ 
				"imgAuthor=?,"+ 
				"videoPath=?," +
				"videoTitle=?," + // luxiang
				"videoAuthor=?," + // zhaopian
				"saveStates=? " + // 保护状态
				" where id=?";
		db.beginTransaction();
		try {
			db.execSQL(
					sql,
					new String[] { 
							wzmlInfo.surveyArea,
							String.valueOf(wzmlInfo.surveyAreaPosition),
							wzmlInfo.chineseName, 
							wzmlInfo.latinName, 
							wzmlInfo.commonName,
							String.valueOf(wzmlInfo.characters),
							String.valueOf(wzmlInfo.distributionTypePosition),
							wzmlInfo.distributionArea,
							wzmlInfo.environmentFeature,
							wzmlInfo.elevationBegin,
							wzmlInfo.elevationEnd,
							String.valueOf(wzmlInfo.level),
							String.valueOf(wzmlInfo.niche),
							String.valueOf(wzmlInfo.isOrigin),
							String.valueOf(wzmlInfo.endemism),
							String.valueOf(wzmlInfo.degrees),
							wzmlInfo.use,
							wzmlInfo.nationalUse,
							String.valueOf(wzmlInfo.threatStates),
							wzmlInfo.threatFactors, 
							String.valueOf(wzmlInfo.saveGradeInCountry),
							String.valueOf(wzmlInfo.saveGradeInPrivince),
							String.valueOf(wzmlInfo.saveGradeInCITES),
							String.valueOf(wzmlInfo.saveGradeInRed),
							wzmlInfo.imgPath,
							wzmlInfo.imgTitle,
							wzmlInfo.imgAuthor,
							wzmlInfo.videoPath,
							wzmlInfo.videoTitle,
							wzmlInfo.videoAuthor,
							String.valueOf(wzmlInfo.saveStates),
							String.valueOf(id) });
		} catch (Exception e) {
			e.printStackTrace();
			return false;
		} finally {
			if (db.isOpen()) {
				db.setTransactionSuccessful();
				db.endTransaction();
				db.close();
			}
		}
		return true;
	}
}
